package com.binguo.checker;

import com.binguo.common.exception.ServiceException;
import com.binguo.model.repository.CustomerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import static com.binguo.common.exception.ErrorCode.CUSTOMER_NOT_EXIST;

/**
 * Created by haibang on 18/5/21.
 */
@Component
public class CustomerChecker {

    @Autowired
    CustomerRepository customerRepository;


    public void checkNotExist(Integer customerId){
        if(customerRepository.findById(customerId)==null) throw new ServiceException(CUSTOMER_NOT_EXIST);
    }

}
